package com.gitee.feizns.upload.config;

import com.gitee.feizns.upload.config.interceptors.AuthorizationInterceptor;
import com.gitee.feizns.upload.domain.prop.AuthorizationConfigProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author feizns
 * @since 2019/8/9
 */
@Configuration
@EnableConfigurationProperties(AuthorizationConfigProperties.class)
public class WebAutoConfiguration implements WebMvcConfigurer {

    @Autowired
    private AuthorizationConfigProperties properties;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new AuthorizationInterceptor(properties));
    }

}
